package com.tjvib.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.tjvib.R;
import com.tjvib.bean.LpmsB2SensorSelect;

import java.util.List;

public class LpmsB2SensorSelectAdapter extends BaseQuickAdapter<LpmsB2SensorSelect, BaseViewHolder> {

    private Context context;
    private List<LpmsB2SensorSelect> lpmsB2SensorSelectList;

    public LpmsB2SensorSelectAdapter(int layoutResId, Context context, @Nullable List<LpmsB2SensorSelect> data) {
        super(layoutResId, data);
        this.context = context;
        this.lpmsB2SensorSelectList = data;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, LpmsB2SensorSelect lpmsB2SensorSelect) {
        baseViewHolder.setText(R.id.item_lpmsb2_sel_tv_name, lpmsB2SensorSelect.getName())
                .setText(R.id.item_lpmsb2_sel_tv_add, lpmsB2SensorSelect.getAddress());

        baseViewHolder.findView(R.id.item_lpmsb2_sel_tv_status).setBackgroundColor(
                context.getResources().getColor(lpmsB2SensorSelect.isSelected() ? R.color.green : R.color.main_grey_0));
    }
}
